package com.guchenbo.bigdata.spark;

import org.apache.spark.SparkConf;
import org.apache.spark.api.java.JavaRDD;
import org.apache.spark.api.java.JavaSparkContext;

import java.util.Arrays;
import java.util.List;

/**
 * @author guchenbo
 */
public class Demo {

    public static void main(String[] args) {
        SparkConf conf = new SparkConf().setAppName("demo").setMaster(args[0]);
        JavaSparkContext sc = new JavaSparkContext(conf);

        List<Integer> list = Arrays.asList(1, 2, 3, 4, 5);
        JavaRDD<Integer> rdd = sc.parallelize(list);

        int count = rdd.reduce((a, b) -> a + b);
        System.out.println(count);
    }
}
